package com.icss.lesson3;

import java.io.*;

public class TestMain4 {

    public static void main(String[] args) {

            // finally自动关闭的变量，
        try (
                InputStream is  = new FileInputStream("D:/a.txt");
                OutputStream os = new FileOutputStream("D:/a_copy.txt");
                ){

            // 实例化一个 字节输入流
            byte[] buffer = new byte[10]; // {0,0.0,0,0,0,0,0,0,0,}
            int len = -1;
            while (( len = is.read(buffer)) != -1) {
                os.write(buffer, 0, len);
                System.out.print(new String(buffer,0, len, "utf-8"));
            }

            // 必须推
            os.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
